package com.skillworld.webapp.model.complaint;

import java.util.Calendar;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.skillworld.webapp.model.tutorial.Tutorial;
import com.skillworld.webapp.model.user.User;

@Entity
@Table(name="Complaint")
public class Complaint {

    public enum Type { OFFENSIVE, PLAGIARISM, OTHER }
    
	private Long complaintId;
	private Calendar date;
	private String text;
	private Type type;
	private Tutorial tutorial;
	private User user;

		
	protected Complaint() 
	{

    }

    public Complaint(Calendar date, String text, Type type, Tutorial tutorial,
                        User user)
	{
        this.date = date;
        this.text = text;
        this.type = type;
        this.tutorial = tutorial;
        this.user = user;
    }

    
    @SequenceGenerator(name="ComplaintIdGenerator",sequenceName="ComplaintSeq")
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO,generator="ComplaintIdGenerator")
	@Column(name="idComplaint")
	public Long getComplaintId() {
		return complaintId;
	}
	
	public void setComplaintId(Long complaintId) {
		this.complaintId = complaintId;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="date")
	public Calendar getDate() {
		return date;
	}
	
	public void setDate(Calendar date) {
		this.date = date;
	}
	
	@Column(name="text")
	public String getText() {
		return text;
	}
	
	public void setText(String text) {
		this.text = text;
	}
	
	@Enumerated(EnumType.STRING)
	@Column(name="type")
	public Type getType() {
		return type;
	}
	
	public void setType(Type type) {
		this.type = type;
	}
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="idTutorial")
	public Tutorial getTutorial() {
		return tutorial;
	}
	
	public void setTutorial(Tutorial tutorial) {
		this.tutorial = tutorial;
	}
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="idUser")
	public User getUser() {
		return user;
	}
	
	public void setUser(User user) {
		this.user = user;
	}

}
